      function formatTime(date) {
        var year = date.getFullYear()
        var month = date.getMonth() + 1
        var day = date.getDate()

        var hour = date.getHours()
        var minute = date.getMinutes()
        var second = date.getSeconds()

        return [year, month, day].map(formatNumber).join('-')
        // + ' ' + [hour, minute, second].map(formatNumber).join(':')
      }
      function formatNumber(n) {
        n = n.toString()
        return n[1] ? n : '0' + n
      }
      function getYearMonth(date){
        return date.getFullYear()+"-"+formatNumber(date.getMonth()+1);
      }
      function getDaysOfMonth(year, month) {  
        // 将输入的年月转换为Date对象  
        var date = new Date(year, month - 1); // 注意，月份从0开始计数，所以需要减1  
        
        // 创建一个空数组来存储该月的所有天数  
        var days = [];  
        
        // 循环从该月的第一天到最后一天，并将每个日期添加到数组中  
        for (var day = 1; day <= date.getDate(); day++) {  
          days.push(new Date(date.getFullYear(), date.getMonth(), day));  
        }  
        
        return days;  
      } 
      function formatDateToStr(time, pattern) {
        var year = time.getFullYear();
        var month = time.getMonth() + 1;
        var day = time.getDate();
        var hour = time.getHours();
        var minute = time.getMinutes();
        var second = time.getSeconds();
        if (pattern === 'yyyy-MM-dd hh:mm:ss') {
          return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day) + ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (minute < 10 ? '0' + minute : minute) + ':' + (second < 10 ? '0' + second : second);
        } else if (pattern === 'yyyy-MM-dd') {
          return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
        }
      }
      function mapToConds(map){
        let conds = [];
        map && Object.keys(map).forEach(key=>{
          conds.push({col:key,val:map[key]});
        });
        return conds;
      }
      function formValid(form,rules){
        const msg = [];
        form && Object.keys(form).forEach(key=>{
          if(rules[key] && rules[key].length>0){
            rules[key].forEach(rule=>{
              if(rule.required && (form[key]===null || form[key]===undefined || form[key]==='')){
                msg.push(rule.message);
              }
            });
          }
        });
        if(msg.length>0){
          wx.showToast({
            title: msg.join("，"),
            icon: 'error',
            duration: 2000
          });
        }
        return msg.length==0;
      }
      module.exports = {
        formatTime: formatTime,
        getYearMonth:getYearMonth,
        getDaysOfMonth:getDaysOfMonth,
        mapToConds:mapToConds,
        formatDateToStr:formatDateToStr,
        formValid:formValid
      }